#include "Bullet.h"

int CBullet::countBullet=0;
CBullet::CBullet(void)
{
}
CBullet::CBullet(QuadTree* q,Direction dir,int left, int top,CScreen *scr)
{
	_imageBullet=CSprites::LoadTexture("Images\\Effect.png",0);
	lastTime=GetTickCount();
	vX=BULLET_SPEED;
	_typeObj=4;
	_layer=1;
	_quadTree=q;
	_pRECT->left=left;_pRECT->top=top;
	_pRECT->right=_pRECT->left+17;
	_pRECT->bottom=_pRECT->top+17;
	_kind=0;
	_isActive=true;
	_status=1;
	_pSprite=new CSprites(_imageBullet,true,0,4,0,16,16,left,top+16,120,150);
	_direction=dir;
	_isUpDown = true ; _deltaY = 0;
	isUp=false;
	_screen=scr;
}
void CBullet::Draw(int VirtualLeft, int Style)
{
	_pSprite->Draw(VirtualLeft,0,true);
}
int CBullet::Move()
{
	if(GetTickCount()-lastTime<DELTA_TIME)
		return 0;
	lastTime=GetTickCount();
	int DeltaX=0;
	if(_isActive&&_status!=2)//'s not died yet.
	{
		DeltaX=CheckLeftRight();
		_pRECT->left+=DeltaX;
		_pRECT->right+=DeltaX;
		_pSprite->_left+=DeltaX;
		if(DeltaX==0||_pRECT->top>WINDOW_HEIGHT||_pRECT->left-_screen->Camera.left>WINDOW_WIDTH)//Blow
		{
			_status=2;		
			_pRECT->top=WINDOW_HEIGHT+10;
			_pRECT->bottom=_pRECT->top+50;
			return 0;
		}
		if(_status==0)
		{
			_status=1;
			_isUpDown = true ; _deltaY = 10;
			isUp=true;
		}
	}
	Jump();
	return DeltaX;
}
void CBullet::Collision(Object *Ob)
{
}
CBullet::~CBullet(void)
{
}

